const Base = require('./base.js');

const jwt = require('jsonwebtoken')


module.exports = class extends Base {
  indexAction() {
    console.log('Action')

    // Token 数据
const payload = {
  name: 'wanghao',
  admin: true
}

// // 密钥
const secret = 'ILOVENINGHAO'

// // 签发 Token
// const token = jwt.sign(payload, secret, { expiresIn: '1day' })

// // 输出签发的 Token
// console.log(token)
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoid2FuZ2hhbyIsImFkbWluIjp0cnVlLCJpYXQiOjE1NTIwMjgzODksImV4cCI6MTU1MjExNDc4OX0.PKNotP5HLw0PLexs7Uyc1KVwDcpeX7xk-DZIGTTrmaA'
// const token = '13213.eyJuYW1lIjoid2FuZ2hhbyIsImFkbWluIjp0cnVlLCJpYXQiOjE1NTIwMjgzODksImV4cCI6MTU1MjExNDc4OX0.PKNotP5HLw0PLexs7Uyc1KVwDcpeX7xk-DZIGTTrmaA'

// 验证 Token
jwt.verify(token, secret, (error, decoded) => {
  if (error) {
    console.log(error.message)
    return
  }
  console.log(decoded)
})

    return this.display();
  }
};
